{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import QUANTAXIS as QA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "此特性 为 QUANTAXIS 1.7.7 新增, 请升级QA\n"
     ]
    }
   ],
   "source": [
    "print('此特性 为 QUANTAXIS {} 新增, 请升级QA'.format(QA.__version__))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "user = QA.QA_User(username='admin', password='admin')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " prortfolio with user_cookie  USER_lT8yva0f  already exist!!\n"
     ]
    }
   ],
   "source": [
    "port = user.new_portfolio('test_newAccounts')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "x1 = port.new_account('x1', market_type=QA.MARKET_TYPE.FUTURE_CN)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.history"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "< QA_Order realorder_id Order_pIsgG8Jo datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_pIsgG8Jo account:x1 status:queued >"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.buy('RBL8', 3600, amount=1, time = '2020-01-10')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "QAACCOUNT ==> receive deal 2020-01-10 09:31:00 RBL8 3600.0 2\n"
     ]
    }
   ],
   "source": [
    "x1.buy('RBL8', 3600, amount=1, time = '2020-01-10', if_selfdeal=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>code</th>\n",
       "      <th>price</th>\n",
       "      <th>amount</th>\n",
       "      <th>cash</th>\n",
       "      <th>order_id</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>commission</th>\n",
       "      <th>tax</th>\n",
       "      <th>message</th>\n",
       "      <th>frozen</th>\n",
       "      <th>direction</th>\n",
       "      <th>total_frozen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-01-10 09:31:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3600.0</td>\n",
       "      <td>1</td>\n",
       "      <td>996756.4</td>\n",
       "      <td>Order_vZVmT2cA</td>\n",
       "      <td>Order_vZVmT2cA</td>\n",
       "      <td>buy</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3240.0</td>\n",
       "      <td>2</td>\n",
       "      <td>3240.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              datetime  code   price  amount      cash        order_id  \\\n",
       "0  2020-01-10 09:31:00  RBL8  3600.0       1  996756.4  Order_vZVmT2cA   \n",
       "\n",
       "     realorder_id trade_id account_cookie  commission  tax message  frozen  \\\n",
       "0  Order_vZVmT2cA      buy             x1         3.6    0    None  3240.0   \n",
       "\n",
       "   direction  total_frozen  \n",
       "0          2        3240.0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.history_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[< QA_Order realorder_id Order_pIsgG8Jo datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_pIsgG8Jo account:x1 status:queued >]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.orders.pending"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>_status</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>amount</th>\n",
       "      <th>amount_model</th>\n",
       "      <th>broker</th>\n",
       "      <th>callback</th>\n",
       "      <th>cancel_amount</th>\n",
       "      <th>code</th>\n",
       "      <th>commission_coeff</th>\n",
       "      <th>date</th>\n",
       "      <th>...</th>\n",
       "      <th>strategy</th>\n",
       "      <th>tax_coeff</th>\n",
       "      <th>time_condition</th>\n",
       "      <th>towards</th>\n",
       "      <th>trade_amount</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>trade_price</th>\n",
       "      <th>trade_time</th>\n",
       "      <th>type</th>\n",
       "      <th>user_cookie</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>queued</td>\n",
       "      <td>x1</td>\n",
       "      <td>1</td>\n",
       "      <td>by_amount</td>\n",
       "      <td>backtest</td>\n",
       "      <td>&lt;bound method QA_Account.receive_deal of &lt; QA_...</td>\n",
       "      <td>0</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>0.00025</td>\n",
       "      <td>2020-01-10</td>\n",
       "      <td>...</td>\n",
       "      <td>None</td>\n",
       "      <td>0.001</td>\n",
       "      <td>GFD</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>0.0</td>\n",
       "      <td>[]</td>\n",
       "      <td>future_cn</td>\n",
       "      <td>USER_lT8yva0f</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>success_all</td>\n",
       "      <td>x1</td>\n",
       "      <td>1</td>\n",
       "      <td>by_amount</td>\n",
       "      <td>backtest</td>\n",
       "      <td>&lt;bound method QA_Account.receive_deal of &lt; QA_...</td>\n",
       "      <td>0</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>0.00025</td>\n",
       "      <td>2020-01-10</td>\n",
       "      <td>...</td>\n",
       "      <td>None</td>\n",
       "      <td>0.001</td>\n",
       "      <td>GFD</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>[buy]</td>\n",
       "      <td>3600.0</td>\n",
       "      <td>[2020-01-10 09:31:00]</td>\n",
       "      <td>future_cn</td>\n",
       "      <td>USER_lT8yva0f</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2 rows × 33 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       _status account_cookie  amount amount_model    broker  \\\n",
       "0       queued             x1       1    by_amount  backtest   \n",
       "0  success_all             x1       1    by_amount  backtest   \n",
       "\n",
       "                                            callback  cancel_amount  code  \\\n",
       "0  <bound method QA_Account.receive_deal of < QA_...              0  RBL8   \n",
       "0  <bound method QA_Account.receive_deal of < QA_...              0  RBL8   \n",
       "\n",
       "   commission_coeff        date  ... strategy tax_coeff time_condition  \\\n",
       "0           0.00025  2020-01-10  ...     None     0.001            GFD   \n",
       "0           0.00025  2020-01-10  ...     None     0.001            GFD   \n",
       "\n",
       "  towards trade_amount  trade_id trade_price             trade_time  \\\n",
       "0       2            0        []         0.0                     []   \n",
       "0       2            1     [buy]      3600.0  [2020-01-10 09:31:00]   \n",
       "\n",
       "        type    user_cookie  \n",
       "0  future_cn  USER_lT8yva0f  \n",
       "0  future_cn  USER_lT8yva0f  \n",
       "\n",
       "[2 rows x 33 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.orders.to_df()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "RBL8    1\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.hold_table()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "QAACCOUNT ==> receive deal 2020-01-13 09:31:00 RBL8 3603.0 -3\n"
     ]
    }
   ],
   "source": [
    "x1.sell_close('RBL8', 3603, amount=1, time = '2020-01-13', if_selfdeal=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>code</th>\n",
       "      <th>price</th>\n",
       "      <th>amount</th>\n",
       "      <th>cash</th>\n",
       "      <th>order_id</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>commission</th>\n",
       "      <th>tax</th>\n",
       "      <th>message</th>\n",
       "      <th>frozen</th>\n",
       "      <th>direction</th>\n",
       "      <th>total_frozen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-01-10 09:31:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3600.0</td>\n",
       "      <td>1</td>\n",
       "      <td>996756.400</td>\n",
       "      <td>Order_vZVmT2cA</td>\n",
       "      <td>Order_vZVmT2cA</td>\n",
       "      <td>buy</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.600</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3240.0</td>\n",
       "      <td>2</td>\n",
       "      <td>3240.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-01-13 09:31:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3603.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>1000022.797</td>\n",
       "      <td>Order_NVimxwQM</td>\n",
       "      <td>Order_NVimxwQM</td>\n",
       "      <td>sellclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.603</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              datetime  code   price  amount         cash        order_id  \\\n",
       "0  2020-01-10 09:31:00  RBL8  3600.0       1   996756.400  Order_vZVmT2cA   \n",
       "1  2020-01-13 09:31:00  RBL8  3603.0      -1  1000022.797  Order_NVimxwQM   \n",
       "\n",
       "     realorder_id   trade_id account_cookie  commission  tax message  frozen  \\\n",
       "0  Order_vZVmT2cA        buy             x1       3.600    0    None  3240.0   \n",
       "1  Order_NVimxwQM  sellclose             x1       3.603    0    None     0.0   \n",
       "\n",
       "   direction  total_frozen  \n",
       "0          2        3240.0  \n",
       "1         -3           0.0  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.history_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "x1.reset_assets(1000000)  # 重置账户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>code</th>\n",
       "      <th>price</th>\n",
       "      <th>amount</th>\n",
       "      <th>cash</th>\n",
       "      <th>order_id</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>commission</th>\n",
       "      <th>tax</th>\n",
       "      <th>message</th>\n",
       "      <th>frozen</th>\n",
       "      <th>direction</th>\n",
       "      <th>total_frozen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [datetime, code, price, amount, cash, order_id, realorder_id, trade_id, account_cookie, commission, tax, message, frozen, direction, total_frozen]\n",
       "Index: []"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.history_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE\n",
      "QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'source': 'account',\n",
       " 'frequence': 'day',\n",
       " 'account_cookie': 'x1',\n",
       " 'portfolio_cookie': 'test_newAccounts',\n",
       " 'user_cookie': 'USER_lT8yva0f',\n",
       " 'broker': 'backtest',\n",
       " 'market_type': 'future_cn',\n",
       " 'strategy_name': None,\n",
       " 'current_time': 'None',\n",
       " 'allow_sellopen': True,\n",
       " 'allow_margin': True,\n",
       " 'allow_t0': True,\n",
       " 'margin_level': {},\n",
       " 'init_assets': {'cash': 1000000, 'hold': {}},\n",
       " 'init_cash': 1000000,\n",
       " 'init_hold': {},\n",
       " 'commission_coeff': 0.00025,\n",
       " 'tax_coeff': 0.001,\n",
       " 'cash': [1000000],\n",
       " 'history': [],\n",
       " 'trade_index': [],\n",
       " 'running_time': '2020-01-15 00:28:34.722473',\n",
       " 'quantaxis_version': '1.7.5',\n",
       " 'running_environment': 'backtest',\n",
       " 'start_date': None,\n",
       " 'end_date': None,\n",
       " 'frozen': {},\n",
       " 'finished_id': []}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.message"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "QAACCOUNT ==> receive deal 2019-12-03 00:00:00 RBL8 3599.0 2\n",
      "QAACCOUNT ==> receive deal 2019-12-04 00:00:00 RBL8 3603.0 -3\n",
      "QAACCOUNT ==> receive deal 2019-12-05 00:00:00 RBL8 3585.0 -2\n",
      "QAACCOUNT ==> receive deal 2019-12-09 00:00:00 RBL8 3511.0 3\n",
      "QAACCOUNT ==> receive deal 2019-12-11 00:00:00 RBL8 3537.0 -2\n",
      "QAACCOUNT ==> receive deal 2019-12-12 00:00:00 RBL8 3524.0 3\n",
      "QAACCOUNT ==> receive deal 2019-12-13 00:00:00 RBL8 3523.0 2\n",
      "QAACCOUNT ==> receive deal 2019-12-16 00:00:00 RBL8 3480.0 -3\n",
      "QAACCOUNT ==> receive deal 2019-12-18 00:00:00 RBL8 3476.0 2\n",
      "QAACCOUNT ==> receive deal 2019-12-19 00:00:00 RBL8 3518.0 -3\n",
      "QAACCOUNT ==> receive deal 2019-12-24 00:00:00 RBL8 3510.0 -2\n",
      "QAACCOUNT ==> receive deal 2019-12-25 00:00:00 RBL8 3485.0 3\n",
      "QAACCOUNT ==> receive deal 2019-12-30 00:00:00 RBL8 3545.0 -2\n",
      "QAACCOUNT ==> receive deal 2020-01-09 00:00:00 RBL8 3555.0 3\n"
     ]
    }
   ],
   "source": [
    "x1.generate_randomtrade('RBL8', '2019-12-01', '2020-01-10', 'day') ## 生成随机交易"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>code</th>\n",
       "      <th>price</th>\n",
       "      <th>amount</th>\n",
       "      <th>cash</th>\n",
       "      <th>order_id</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>commission</th>\n",
       "      <th>tax</th>\n",
       "      <th>message</th>\n",
       "      <th>frozen</th>\n",
       "      <th>direction</th>\n",
       "      <th>total_frozen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2019-12-03 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3599.0</td>\n",
       "      <td>1</td>\n",
       "      <td>996757.301</td>\n",
       "      <td>Order_XcSehQp4</td>\n",
       "      <td>Order_XcSehQp4</td>\n",
       "      <td>buy</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.599</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3239.1</td>\n",
       "      <td>2</td>\n",
       "      <td>3239.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2019-12-04 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3603.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>1000032.798</td>\n",
       "      <td>Order_gTqCzn0Z</td>\n",
       "      <td>Order_gTqCzn0Z</td>\n",
       "      <td>sellclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.603</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2019-12-05 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3585.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>996802.713</td>\n",
       "      <td>Order_CgIGabZL</td>\n",
       "      <td>Order_CgIGabZL</td>\n",
       "      <td>sell</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.585</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3226.5</td>\n",
       "      <td>-2</td>\n",
       "      <td>3226.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2019-12-09 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3511.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1000765.702</td>\n",
       "      <td>Order_8T7amXgp</td>\n",
       "      <td>Order_8T7amXgp</td>\n",
       "      <td>buyclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.511</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2019-12-11 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3537.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>997578.865</td>\n",
       "      <td>Order_rLUOFvGB</td>\n",
       "      <td>Order_rLUOFvGB</td>\n",
       "      <td>sell</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.537</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3183.3</td>\n",
       "      <td>-2</td>\n",
       "      <td>3183.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2019-12-12 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3524.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1000888.641</td>\n",
       "      <td>Order_T1vV9MUx</td>\n",
       "      <td>Order_T1vV9MUx</td>\n",
       "      <td>buyclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.524</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2019-12-13 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3523.0</td>\n",
       "      <td>1</td>\n",
       "      <td>997714.418</td>\n",
       "      <td>Order_Ao2MD38I</td>\n",
       "      <td>Order_Ao2MD38I</td>\n",
       "      <td>buy</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.523</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3170.7</td>\n",
       "      <td>2</td>\n",
       "      <td>3170.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2019-12-16 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3480.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>1000451.638</td>\n",
       "      <td>Order_EHfeBhV7</td>\n",
       "      <td>Order_EHfeBhV7</td>\n",
       "      <td>sellclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.480</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2019-12-18 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3476.0</td>\n",
       "      <td>1</td>\n",
       "      <td>997319.762</td>\n",
       "      <td>Order_XLHvkeOj</td>\n",
       "      <td>Order_XLHvkeOj</td>\n",
       "      <td>buy</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.476</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3128.4</td>\n",
       "      <td>2</td>\n",
       "      <td>3128.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2019-12-19 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3518.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>1000864.644</td>\n",
       "      <td>Order_cAkRpNLd</td>\n",
       "      <td>Order_cAkRpNLd</td>\n",
       "      <td>sellclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.518</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2019-12-24 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3510.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>997702.134</td>\n",
       "      <td>Order_zUXtN8wp</td>\n",
       "      <td>Order_zUXtN8wp</td>\n",
       "      <td>sell</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.510</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3159.0</td>\n",
       "      <td>-2</td>\n",
       "      <td>3159.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2019-12-25 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3485.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1001107.649</td>\n",
       "      <td>Order_6HfQFKCd</td>\n",
       "      <td>Order_6HfQFKCd</td>\n",
       "      <td>buyclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.485</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2019-12-30 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3545.0</td>\n",
       "      <td>-1</td>\n",
       "      <td>997913.604</td>\n",
       "      <td>Order_Z35Ts4pg</td>\n",
       "      <td>Order_Z35Ts4pg</td>\n",
       "      <td>sell</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.545</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>3190.5</td>\n",
       "      <td>-2</td>\n",
       "      <td>3190.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2020-01-09 00:00:00</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>3555.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1001000.549</td>\n",
       "      <td>Order_HU6wLCef</td>\n",
       "      <td>Order_HU6wLCef</td>\n",
       "      <td>buyclose</td>\n",
       "      <td>x1</td>\n",
       "      <td>3.555</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               datetime  code   price  amount         cash        order_id  \\\n",
       "0   2019-12-03 00:00:00  RBL8  3599.0       1   996757.301  Order_XcSehQp4   \n",
       "1   2019-12-04 00:00:00  RBL8  3603.0      -1  1000032.798  Order_gTqCzn0Z   \n",
       "2   2019-12-05 00:00:00  RBL8  3585.0      -1   996802.713  Order_CgIGabZL   \n",
       "3   2019-12-09 00:00:00  RBL8  3511.0       1  1000765.702  Order_8T7amXgp   \n",
       "4   2019-12-11 00:00:00  RBL8  3537.0      -1   997578.865  Order_rLUOFvGB   \n",
       "5   2019-12-12 00:00:00  RBL8  3524.0       1  1000888.641  Order_T1vV9MUx   \n",
       "6   2019-12-13 00:00:00  RBL8  3523.0       1   997714.418  Order_Ao2MD38I   \n",
       "7   2019-12-16 00:00:00  RBL8  3480.0      -1  1000451.638  Order_EHfeBhV7   \n",
       "8   2019-12-18 00:00:00  RBL8  3476.0       1   997319.762  Order_XLHvkeOj   \n",
       "9   2019-12-19 00:00:00  RBL8  3518.0      -1  1000864.644  Order_cAkRpNLd   \n",
       "10  2019-12-24 00:00:00  RBL8  3510.0      -1   997702.134  Order_zUXtN8wp   \n",
       "11  2019-12-25 00:00:00  RBL8  3485.0       1  1001107.649  Order_6HfQFKCd   \n",
       "12  2019-12-30 00:00:00  RBL8  3545.0      -1   997913.604  Order_Z35Ts4pg   \n",
       "13  2020-01-09 00:00:00  RBL8  3555.0       1  1001000.549  Order_HU6wLCef   \n",
       "\n",
       "      realorder_id   trade_id account_cookie  commission  tax message  frozen  \\\n",
       "0   Order_XcSehQp4        buy             x1       3.599    0    None  3239.1   \n",
       "1   Order_gTqCzn0Z  sellclose             x1       3.603    0    None     0.0   \n",
       "2   Order_CgIGabZL       sell             x1       3.585    0    None  3226.5   \n",
       "3   Order_8T7amXgp   buyclose             x1       3.511    0    None     0.0   \n",
       "4   Order_rLUOFvGB       sell             x1       3.537    0    None  3183.3   \n",
       "5   Order_T1vV9MUx   buyclose             x1       3.524    0    None     0.0   \n",
       "6   Order_Ao2MD38I        buy             x1       3.523    0    None  3170.7   \n",
       "7   Order_EHfeBhV7  sellclose             x1       3.480    0    None     0.0   \n",
       "8   Order_XLHvkeOj        buy             x1       3.476    0    None  3128.4   \n",
       "9   Order_cAkRpNLd  sellclose             x1       3.518    0    None     0.0   \n",
       "10  Order_zUXtN8wp       sell             x1       3.510    0    None  3159.0   \n",
       "11  Order_6HfQFKCd   buyclose             x1       3.485    0    None     0.0   \n",
       "12  Order_Z35Ts4pg       sell             x1       3.545    0    None  3190.5   \n",
       "13  Order_HU6wLCef   buyclose             x1       3.555    0    None     0.0   \n",
       "\n",
       "    direction  total_frozen  \n",
       "0           2        3239.1  \n",
       "1          -3           0.0  \n",
       "2          -2        3226.5  \n",
       "3           3           0.0  \n",
       "4          -2        3183.3  \n",
       "5           3           0.0  \n",
       "6           2        3170.7  \n",
       "7          -3           0.0  \n",
       "8           2        3128.4  \n",
       "9          -3           0.0  \n",
       "10         -2        3159.0  \n",
       "11          3           0.0  \n",
       "12         -2        3190.5  \n",
       "13          3           0.0  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.history_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1.hold_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
